/*
 * Copyright (c) 2021.
 * @User: XiaoZhenRS
 * @QQ: 1419158026
 * @Gitee: gitee.com/XiaoZhengRS
 * @GitHub: github.com/XiaoZhengRS
 */

package com.xiaozhengkeji.starbootserver.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import wiki.xsx.core.util.RedisUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
@Slf4j
public class CorsInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Long temp_size = RedisUtil.getNumberHandler(2).getLong("loadAmount");
        if (temp_size == null) {
            RedisUtil.getNumberHandler(2).setLong("loadAmount", 0L);
        }else {
            RedisUtil.getNumberHandler(2).setLong("loadAmount", temp_size + 1);
        }
        return true;
    }
}
